package yi1019;

import java.util.Scanner;

/**
 * @author tmh
 * @date 2024/10/19 12:10
 * @description
 * 5 2
 * 8 6 1 5 1
 * 4 4 3 4 6
 */
public class T1 {
    public static void main(String[] args) {
        while (true) {
            Scanner scanner = new Scanner(System.in);

            int result  =1;
            int maxResult=0;
            int count = scanner.nextInt();
            int k = scanner.nextInt();
            int[] xArray = new int[count];
            int[] yArray = new int[count];
            for (int i = 0; i < count; i++) {
                xArray[i] = scanner.nextInt();
            }
            for (int i = 0; i < count; i++) {
                yArray[i] = scanner.nextInt();
            }
            for (int i = 0; i < count; i++) {
                for (int j = i+1; j < count; j++) {
                    int distance= Math.abs(xArray[i]-xArray[j])+Math.abs(yArray[i]-yArray[j]);
                    if (distance<=k){
                        result++;
                        if (result>maxResult){
                            maxResult=result;
                        }
                    }
                }
            }
            System.out.println(maxResult);
        }
    }
}
